package com.ycw.servlet.wangwang;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.ycw.dao.ContractDao;
import com.ycw.dao.impl.ContractDaoImpl;
import com.ycw.pojo.Contract;

@WebServlet("/doUpdateServlet")
public class doUpdateServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		ContractDao cd = new ContractDaoImpl();

		int c_id = Integer.parseInt(request.getParameter("c_id"));

		int h_id = Integer.parseInt(request.getParameter("h_id"));

		String c_num = request.getParameter("c_num");
		String c_alltime = request.getParameter("c_alltime");
		String c_begintime = request.getParameter("c_begintime");
		String c_endtime = request.getParameter("c_endtime");
		String c_total = request.getParameter("c_total");
		String c_mode = request.getParameter("c_mode");
		String c_deposit = request.getParameter("c_deposit");
		String c_count = request.getParameter("c_count");
		String c_signer = request.getParameter("c_signer");
		String c_state = request.getParameter("c_state");
		Contract constract = new Contract(c_id, c_num, h_id, c_alltime, c_begintime, c_endtime, c_total, c_mode,
				c_deposit, c_count, c_signer, c_state);

		int bl = cd.contractUpdate(constract);
		// 向前端发送JSON数据
		String resJSON = JSON.toJSONString(bl);
		PrintWriter out = response.getWriter();
		out.write(resJSON);
		out.close();
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doPost(request, response);

	}

}
